package com.yhao.stock.scheduler;

import com.yhao.stock.common.service.SHService;
import com.yhao.stock.common.utils.DateUtil;
import com.yhao.stock.entity.StockInfo;
import com.yhao.stock.service.StockInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author : yhao
 * @Date : 2023/11/10 - 14:40
 * @Desc : TODO
 */
@Component
@Slf4j
public class GetHisDataScheduler {

    @Autowired
    private SHService shService;

    @Autowired
    private StockInfoService stockInfoService;

    @Scheduled(cron = "0 0 17 ? * MON-FRI")
    public void getDataByDay() {
        List<StockInfo> list = stockInfoService.list();
        for (StockInfo stockInfo : list) {
            shService.getTodayInfo(stockInfo.getdCode(), stockInfo.getdName());
        }
        log.info("获取当日数据完成" + DateUtil.getCommonDate());
    }

}
